﻿/*** MikeWare Framework ************************************
* This class is part of product of MikeWare.Framework.
* 
* Author      : Mike Cheers
* Mail        : mikecheers@126.com
* Create Date : 2018/9/16
* Summary     : 
* 
* 
* Modified By : 
* Date        : 
* Mail        : 
* Comment     : 
**************************************************************/

namespace MikeWare.Components.MikeLoggor.Policies
{
    using System;
    using MikeWare.Components.MikeLoggor.Listeners;

    public class RecordsTriggeringPolicy : RollingPolicy
    {
        public Int64 RecordCountLimit = 5000;

        public RecordsTriggeringPolicy(Settings setting) : base(setting) { Int64.TryParse(Setting.Value, out RecordCountLimit); }

        public override bool ShouldRolling(Listener listener)
        {
            if (listener is FileWriterListener)
            {
                return (listener as FileWriterListener).CurrentLogRecordCount >= RecordCountLimit;
            }

            return false;
        }
    }
}
